package net.googlecode.demenkov.services;

import net.googlecode.demenkov.domains.Faculty;
import net.googlecode.demenkov.domains.Group;
import net.googlecode.demenkov.domains.Person;
import net.googlecode.demenkov.domains.University;

import java.util.List;

/**
 * Interface of service that provide actions with person
 *
 * @author Demenkov Yura
 */
public interface PersonService {
    /**
     * Creates person in database
     *
     * @param person to create in database
     */
    public void createPerson(Person person);

    /**
     * Gets person with personId from database
     *
     * @param id of person
     * @return person, if there is person with such id, or null, if there is no
     */
    public Person getPerson(int id);

    /**
     * Updates person in database
     *
     * @param person to update in database
     */
    public void updatePerson(Person person);

    /**
     * Finds person by it's email in database
     *
     * @param email of person
     * @return person, if there is such email in database, or null, if there is no
     */
    public Person findPersonByEmail(String email);


    /**
     * Finds group by groupname,facultyname and universityname in database
     *
     * @param groupName
     * @param factultyName
     * @param universityName
     * @return group, if there is such group in database, or null, if not
     */
    public Group findGroupByGroupNameAndFacultyNameAndUniversityName(String groupName, String factultyName, String universityName);

    /**
     * Finds all groups by facultyname and universityname in database
     *
     * @param facultyName
     * @param universityName
     * @return list of groups
     */
    public List<Group> findAllGroupsByFacultyNameAndUniversityName(String facultyName, String universityName);

    /**
     * Gets university with universityId from database
     *
     * @param universityId of university
     * @return university, if there is university with such id in database, or null if not
     */
    public University getUniversity(int universityId);

    /**
     * Gets group with groupId from database
     *
     * @param groupId of group
     * @return group, if there is group with such id in database, or null if not
     */
    public Group getGroup(int groupId);

    /**
     * Creates group with groupname, facultyname and universityname in database
     *
     * @param groupName
     * @param facultyName
     * @param universityName
     */
    public void createGroup(String groupName, String facultyName, String universityName);

    /**
     * Creates new vote in database from fromPerson for toPerson
     *
     * @param fromPerson person who votes
     * @param toPerson   person who is voted for
     */
    public void createVote(Person fromPerson, Person toPerson);

    /**
     * Deletes vote from database from fromPerson for toPerson
     *
     * @param fromPerson person who voted
     * @param toPerson   person who was voted for
     */
    public void deleteVote(Person fromPerson, Person toPerson);

    /**
     * Gets faculty by faculty Id
     *
     * @param facultyId of faculty
     * @return faculty, if there is faculty with such Id in database or null, if not
     */
    public Faculty getFaculty(int facultyId);

    /**
     * Finds all faculties by universityname in database
     *
     * @param universityName
     * @return list of faculties
     */
    public List<Faculty> findAllFacultiesByUniversityName(String universityName);

    /**
     * Gets all universities from database
     *
     * @return list of universities
     */
    public List<University> getAllUniversities();
}
